<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>PHP数组</title>
</head>

<body>
    <?php
    //写任意接口的时候，都是输出的数组
    /* $arr = array('小明','小红','小亮');
    echo $arr[0];
    echo $arr[1];
    echo $arr[2];

    //数组长度
    echo count($arr);

    //字符串长度
    echo strlen($arr[1]); */


    //关联数组
    /* $arr2=array("小明"=>"10","小红"=>"20","小亮"=>"30");
    var_dump($arr2);
    echo $arr2["小红"];
    foreach($arr2 as $x=>$x_value){
        echo $x;
        echo "<br>";
        echo $x_value;
    } */


    //二维数组
    /*  $arr3=array(
        array("10","20","30"),
        array("100","200","300"),
        array("1000","2000","3000")
    );
    var_dump($arr3);
    echo $arr3[1][1]; */


    //多维数组
    /* $arr4=array(
        "nav"=>array('10','20'),
        "banner"=>array('30','40'),
        "shops"=>array('50','60')
    );
    var_dump($arr4);
    echo $arr4['nav'][0]; */



    //数组排序
    $arr5 = ['ming', 'hong', 'liang'];
    //sort()数组进行升序排序
    sort($arr5);
    var_dump($arr5);

    $arr6 = ['ming', 'hong', 'liang'];
    //rsort()降序
    rsort($arr6);
    var_dump($arr6);

    $arr7 = [10, 7, 4, 9, 20];
    sort($arr7);
    var_dump($arr7);

    $arr8 = ["ming" => "10", "hong" => "20", "liang" => "15"];
    //asort 根据相关数组的值，对数组进行升序排序
    asort($arr8);
    var_dump($arr8);

    $arr9 = ["ming" => "10", "hong" => "20", "liang" => "15"];
    // ksort  根据键 升序排序
    ksort($arr9);
    var_dump($arr9);
    //arsort 根据数组的值，降序
    arsort($arr9);
    var_dump($arr9);

    //krsort 根据数组的键，降序
    krsort($arr9);
    var_dump($arr9);


    ?>
</body>

</html>